/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jlibrarian.entities;

/**
 *
 * @author dandelion8
 */
public class Book 
{
    private int bid;
    private String title;
    private String authors;
    private String note;
    private int quantity;
    // availabile
    private int borrowed;

    
    

    /**
     * Creates a new book.
     */
    public Book()
    {
    }

    /**
     * Creates a new book.
     * @param title     Title of the book
     * @param authors    Author of the book
     * @param quantity  Number of available books
     * @param note      Description of the book
     */
    public Book(String title, String authors, int quantity, String note) {
        this.setTitle(title);
        this.setAuthors(authors);
        this.setQuantity(quantity);
        this.setNote(note);
    }

    /**
     * Returns the title of the book.
     * @return Title of the book
     */
    public String getTitle() {
        return title;
    }

    /**
     * Sets the title of the book.
     * @param title Title
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * Returns the authors of the book.
     * @return Book authors
     */
    public String getAuthors() {
        return authors;
    }

    /**
     * Sets the authors of the book.
     * @param authors Author
     */
    public void setAuthors(String authors) {
        this.authors = authors;
    }

    /**
     * Returns the note, which belongs to the book.
     * @return note Note
     */
    public String getNote() {
        return note;
    }

    /**
     * Sets the note.
     * @param note
     */
    public void setNote(String note) {
        this.note = note;
    }

    /**
     * Returns the number of books.
     * @return
     */
    public int getQuantity() {
        return quantity;
    }

    /**
     * Sets the quantity of books.
     * @param quantity
     */
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
    
    /**
     * This method returns book id.
     * @return Book id.
     */
    public int getBid() {
        return bid;
    }
    
    /**
     * It sets book id.
     * @param bid book id
     */
    public void setBid(int bid) {
        this.bid = bid;
    }
    
    /**
     * Returns borrowed books.
     * @return 
     */
    public int getBorrowed() {
        return borrowed;
    }
    
    /**
     * Returns number of available books.
     * @return 
     */
    public int getAvailable() {
        return this.quantity - this.borrowed;
    }

    /**
     * Sets number of borrowed books
     * @param borrowed Available books 
     */
    public void setBorrowed(int borrowed) {
        this.borrowed = borrowed;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof Book)) {
            return false;
        }
        final Book other = (Book) obj;
        if (this.bid != other.bid) {
            return false;
        }
        return true;
    }

    
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + this.bid;
        return hash;
    }
    
    
    @Override
    public String toString()
    {
        return this.getAuthors() + ": " + this.getTitle();
    }
    
    
}
